<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    p {
      padding: 20px;
      background: #dfb;
    }

    .code {
      user-select: none;
      -ms-user-select: none;
      -webkit-user-select: none;
    }
  </style>
</head>
<body>

  <h1>Hello</h1>

  <p class="code">
    console.log('不能选中')
  </p>

  <p>
    console.log('能够选中')
  </p>
  
</body>
</html>